<!DOCTYPE html>
<html lang="en">
<head>
    <title>商品详情</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/bootstrap/css/bootstrap.min.css" /><!-- bootstrap -->
    <script type="text/javascript" src="/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/jquery-validation/jquery.validate.min.js"></script> <!-- jquery-validator -->
    <script type="text/javascript" src="/jquery-validation/localization/messages_zh.min.js"></script>
    <script type="text/javascript" src="/layer/layer.js"></script><!-- layer -->
    <script type="text/javascript" src="/js/md5.min.js"></script><!-- md5.js -->
    <script type="text/javascript" src="/js/common.js"></script><!-- common.js -->
    <script type="text/javascript" src="/js/paySocket.js"></script><!-- common.js -->
</head>
<body>
<div class="panel panel-default"  style="height:100%;background-color:rgba(222,222,222,0.8)">
    <div class="panel-heading">秒杀订单详情</div>
    <table class="table" id="goodslist">
        <tr>
            <td>商品名称</td>
            <td colspan="3" id="goodName"></td>
        </tr>
        <tr>
            <td>商品图片</td>
            <td colspan="2"><img id="goodImg"  width="200" height="200" /></td>
        </tr>
        <tr>
            <td>订单价格</td>
            <td colspan="2" id="seckillPrice"></td>
        </tr>
        <tr>
            <td>下单时间</td>
            <td colspan="2" id="createDate"></td>
        </tr>
        <tr>
            <td>订单状态</td>
            <td class="status_0" style="display: none">
                未支付
                <button class="btn btn-primary btn-block" type="button" id="payButton" onclick="pay()">立即支付</button>
            </td>
            <td class="status_1" style="display: none">
                已支付
            </td>
            <td class="status_4" style="display: none">
                订单已取消(订单超时)
            </td>
        </tr>
        <tr>
            <td>收货人</td>
            <td colspan="2">叩丁狼  13088889999</td>
        </tr>
        <tr>
            <td>收货地址</td>
            <td colspan="2">广州市天河区棠下街道涌东路大地商务港603</td>
        </tr>
    </table>
</div>
<script>
    var orderNo = getQueryString("orderNo");

    // 发起ajax请求,得到订单信息
    $.ajax({
        url: 'http://localhost:9000/seckill/api/orders/' + orderNo,
        type: "GET",
        xhrFields: {withCredentials: true},
        success: function (res) { // 只有http请求的status=200
            renderOrder(res.data);
        },
        error: function (res) {
            if (res.responseJSON) {
                layer.msg(res.responseJSON.msg);
            }
        }
    });

    function renderOrder(order) {
        $("#goodName").text(order.goodName);
        $("#goodImg").prop("src", order.goodImg);
        $("#seckillPrice").text(order.seckillPrice);
        $("#createDate").text(order.createDate);
        $(".status_" + order.status).css("display", "block");
    }
</script>
</body>
</html>